#[cfg(test)]
mod tests {
    use pkg::httpclient::httpclient;
    use serde::{Deserialize, Serialize};
    use serde_json::json;

    #[derive(Serialize, Deserialize)]
    struct Person {
        name: String,
        age: u8,
        pet_phrase: Vec<String>,
    }

    #[tokio::test]
    async fn test_httpclient() {
        let client = httpclient::HttpClient::new();
        // Actually use the client to remove the warning
        let content = client.post_json("https://amazedown.top/credit_gateway/credit/v1/index/pay/getpay", &json!({"key": "value"})).await;
        println!("{:?}", content)
    }

    #[test]
    fn test_file_storage() {
        let data = r#"
        {
            "name": "James Bond",
            "age": 33,
            "pet_phrase": [
                "Bond, James Bond.",
                "Shaken, not stirred."
            ]
        }"#;

        // 转换成serde_json::Value结构
        let v: serde_json::Value = serde_json::from_str(data).unwrap();

        // 通过方括号建立索引来访问部分数据
        println!("NAME: {}\nAGE: {}\n\t{}\n\t{}",
                 v["name"],
                 v["age"],
                 v["pet_phrase"][0],
                 v["pet_phrase"][1],
        );

    }

    #[test]
    fn test_op(){
        let data = r#"
        {
            "name": "James Bond",
            "age": 33,
            "pet_phrase": [
                "Bond, James Bond.",
                "Shaken, not stirred."
            ]
        }"#;

        // 转换成 Person 结构
        let p: Person = serde_json::from_str(data).unwrap();

        // 通过方括号建立索引来访问部分数据
        println!("NAME: {}\nAGE: {}\n\t{}\n\t{}",
                 p.name,
                 p.age,
                 p.pet_phrase[0],
                 p.pet_phrase[1],
        );
    }
}